<?php 
require("./class.phpmailer.php");   
header("Content-Type:text/html;charset=utf8");
function smtp_mail( $sendto_email, $subject, $body, $extra_hdrs, $user_name){   
    $mail = new PHPMailer();   
    $mail->IsSMTP();                  // send via SMTP   
    $mail->Host = "smtp.163.com";   // SMTP servers   
    $mail->SMTPAuth = true;           // turn on SMTP authentication   
    $mail->Username = "";     // SMTP username  注意：普通邮件认证不需要加 @域名   
    $mail->Password = ""; // SMTP password   
    $mail->From = "";      // 发件人邮箱   
    $mail->FromName =  "管理员";  // 发件人   

    $mail->CharSet = "utf8";   // 这里指定字符集！   
    $mail->Encoding = "base64";   
    $mail->AddAddress("","username");  // 收件人邮箱和姓名   
    $mail->AddReplyTo("yourmail@yourdomain.com","yourdomain.com");   
    //$mail->WordWrap = 50; // set word wrap 换行字数   
    $mail->AddAttachment("./22.docx"); // attachment 附件   
    //$mail->AddAttachment("/tmp/image.jpg", "new.jpg");   
    $mail->IsHTML(true);  // send as HTML   
    // 邮件主题   
    $mail->Subject = $subject;   
    // 邮件内容   
    // $mail->Body = "  
    //     <html><head>  
    //     <meta http-equiv='Content-Language' content='zh-cn'>  
    //     <meta http-equiv='Content-Type' content='text/html; charset=utf8'>  
    //     </head>  
    //     <body>  
    //     I love php。  
    //     </body>  
    //     </html>  
    // ";  
    $mail->Body = "<html><head>  
        <meta http-equiv='Content-Language' content='zh-cn'>  
        <meta http-equiv='Content-Type' content='text/html; charset=utf8'>  
        </head>  
        <body>  
        ".$body."
        </body>  
        </html>  ";                                                                          
    $mail->AltBody ="text/html";   
    if(!$mail->Send())   
    {   
        echo "邮件发送有误 <p>";   
        echo "邮件错误信息: " . $mail->ErrorInfo;   
        exit;   
    }   
    else {   
        echo "$user_name 邮件发送成功!<br />";   
    }   
}   
    // 参数说明(发送到, 邮件主题, 邮件内容, 附加信息, 用户名)   
?> 
